package com.doit.demo02;

public class test_String {
    public static void main(String[] args) {
        String s1 = "abc";
        String s2 = "abc";
//        s2 += "abc";
        System.out.println(s1==s2);//地址值一样,会在方法区创建一个"abc",然后把地址给String
        System.out.println(s1.equals(s2));//内容一样
        System.out.println("----------------------------");
        String s3 = new String("123");//在堆区创建地址后,地址内容是方法区中"123"的地址
        String s4 ="123";
        System.out.println(s3==s4);
        System.out.println(s3.equals(s4));
        System.out.println("------------------------------");
        String s5 = "sDa";
        String s6 = "SdA";
        System.out.println(s5.equals(s6));
        System.out.println(s5.equalsIgnoreCase(s6));//不区分大小写,仅字母,汉字不行就比如一和1和壹是不行的
        System.out.println("----------------------------");
        String s7 = new String ("abc");
        String s8 = new String ("abc");
        System.out.println(s7==s8);
        System.out.println(s7.equals(s8));
    }
}
